package com.cloudlead.common.lang.serialize;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class TypeToken<T> {
	final Type _type;

	protected TypeToken() {
		Type superClass = getClass().getGenericSuperclass();
		if (superClass instanceof Class<?>) { // sanity check, should never
												// happen
			throw new IllegalArgumentException(
					"Internal error: TypeReference constructed without actual type information");
		}
		_type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
	}

	public Type getType() {
		return _type;
	}

}
